Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the shutdown handling in all of the Python examples. #379

Merged

Conversation

clalancette
Copy link
Contributor

In particular, we should deal with KeyboardInterrupt (by just doing 'pass'), as well as ExternalShutdownException (which can come from the executor). In all cases, we should call 'rclpy.try_shutdown()' to cleanup at the end.

Note well that I removed some of the *destroy() calls in the cleanup. That's because they weren't correct in all cases, and to fix them up properly would really require us to have a nested set of try..except statements. Given that these are examples, having that complex set of exception handling didn't seem like the correct way to go here.

This should fix #372 . @fujitatomoya FYI

@clalancette
Copy link
Contributor Author

clalancette commented May 3, 2024

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

In particular, we should deal with KeyboardInterrupt (by
just doing 'pass'), as well as ExternalShutdownException
(which can come from the executor).  In all cases, we should
call 'rclpy.try_shutdown()' to cleanup at the end.

Note well that I removed some of the *destroy() calls in
the cleanup.  That's because they weren't correct in all cases,
and to fix them up properly would really require us to have
a nested set of try..except statements.  Given that these are
examples, having that complex set of exception handling didn't
seem like the correct way to go here.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
@clalancette clalancette force-pushed the clalancette/update-py-example-shutdown-handling branch from 12b295c to 70d4703 Compare May 3, 2024 15:32
@fujitatomoya fujitatomoya self-requested a review May 3, 2024 16:35
@fujitatomoya fujitatomoya self-assigned this May 3, 2024
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual changes lgtm, but the thing we're propgating here is suboptimal, at least in my opinion.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
@clalancette
Copy link
Contributor Author

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette
Copy link
Contributor Author

Going ahead and merging this one in.

@clalancette clalancette merged commit 05aa97e into rolling May 9, 2024
2 of 3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the clalancette/update-py-example-shutdown-handling branch May 9, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Update python nodes SIGINT handling
3 participants